/*
ID:luongho3
LANG:JAVA
TASK:preface
 */
package usaco.training.chap2.sec2;

import java.io.File;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class preface {

	static int N;
	
	static Map<Character,Integer> count = new HashMap<Character,Integer>();
	static char[] letter = {'I','V','X','L','C','D','M'}; // 7
	static Map<Integer,String> map = new HashMap<Integer,String>();
	
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(new File("preface.in"));
		PrintStream ps = new PrintStream(new File("preface.out"));
		System.setOut(ps);
		N = scanner.nextInt();
		for (int i=1;i<=N;++i) {
			String s = roman(i);
			int len = s.length();
			for (int j=0;j<len;++j) {
				char c = s.charAt(j);
				if (!count.containsKey(c)) {
					count.put(c, 1);
				}
				else {
					int val = count.get(c);
					count.put(c, val+1);
				}
			}
		}
		for (int i=0;i<7;++i) {
			if (count.containsKey(letter[i])) {
				int val = count.get(letter[i]);
				System.out.println(letter[i] + " " + val);
			}
		}
//		System.out.println(roman(434));
	}

	private static String roman(int n) {
		StringBuilder builder = new StringBuilder();
		int count = 0;
		while (n > 0) {
			int re = n % 10;
			builder.insert(0,as[count][re]);
			count++;
			n /= 10;
		}
//		builder.reverse();
		return builder.toString();
	}

	static String[][] as = {
		{"","I","II","III","IV","V","VI","VII","VIII","IX"},
		{"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
		{"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
		{"","M","MM","MMM","","","","","",""}
	};
	

}
